package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.order.model.constant.DeliveryHistoryStatusEnum;
import com.ssy.lingxi.order.model.constant.DeliveryOrderOuterStatusEnum;
import com.ssy.lingxi.order.model.constant.ReceiveOrderOuterStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
 * 订单服务测试接口 - 可删除
 * @author 万宁
 * @version 2.0.0
 * @date 2021-09-07
 */
@RestController
@RequestMapping("/order/test")
public class TestController {
    @RequestMapping("/status")
    public String status() {
        return "ok";
    }

    @RequestMapping("/test")
    public String test() throws IOException {
        String filepath = "C:\\Users\\liao5\\Desktop\\messages.properties";

        List<String> content = new ArrayList<>();
        for (DeliveryHistoryStatusEnum value : DeliveryHistoryStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("=").concat(value.getName()));
        }

        content.add("");
        for (DeliveryOrderOuterStatusEnum value : DeliveryOrderOuterStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("=").concat(value.getName()));
        }

        content.add("");
        for (ReceiveOrderOuterStatusEnum value : ReceiveOrderOuterStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("=").concat(value.getName()));
        }

        content.add("");

        Files.write(Paths.get(filepath), content, StandardCharsets.UTF_8);
        return "ok";
    }


}
